home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 10.6 KB | 308 lines | [TEXT/MPS ] |
- // UPrintHandler.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
- //
- // This unit provides stub-outs for printing with MacApp.
- //
- //
- //
-
- #ifndef __UPRINTHANDLER__
- #define __UPRINTHANDLER__
-
- // MacApp
-
- #ifndef __UBEHAVIOR__
- #include "UBehavior.h"
- #endif
-
- #ifndef __UGEOMETRY__
- #include "UGeometry.h"
- #endif
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class TView;
- class TFile;
- class TDocument;
- class TPrintHandler;
- class TPrintInfo;
-
- //----------------------------------------------------------------------------------------
- // Constants
- //----------------------------------------------------------------------------------------
-
- const IDType kPrintBehaviorID = 'prnt'; // behavior id for print handler
- const IDType kPrintMenuBehaviorID = 'prmn'; // behavior id for print menu behavior
-
- //----------------------------------------------------------------------------------------
- // TPrintMenuBehavior
- //----------------------------------------------------------------------------------------
-
- class TPrintMenuBehavior : public TBehavior
- {
- MA_DECLARE_CLASS;
-
- public:
-
- TPrintHandler* fPrintHandler; // the managed print handler
-
- TPrintMenuBehavior();
- // Constructor
- virtual ~TPrintMenuBehavior();
- // Destructor
-
- void IPrintMenuBehavior(TPrintHandler* itsPrintHandler);
- // initializes this behavior, and sets fPrintHandler to itsPrintHandler
-
- //------------------------------------------------------------------------------------
- // Menu Commands
- //------------------------------------------------------------------------------------
-
- virtual Boolean DoScriptCommand(CommandNumber aCommandNumber,
- TAppleEvent* messageEvent,
- TAppleEvent* replyEvent); // override
- // forwards into fPrintHandlers DoScriptCommand
-
- //------------------------------------------------------------------------------------
- // Menu Commands
- //------------------------------------------------------------------------------------
-
- virtual void DoMenuCommand(CommandNumber aCommandNumber);
- // forwards into fPrintHandler's DoPrintCommand
-
- virtual void DoSetupMenus();
- // forwards into fPrintHandler's DoSetupPrintMenus
- };
-
-
- //----------------------------------------------------------------------------------------
- // TPrintHandler: Handles printing at a specified resolution on behalf of a view. This
- // class is really a non-functional stub for programs that don't use the printing building
- // block.
- //----------------------------------------------------------------------------------------
-
- class TPrintHandler : public TBehavior
- {
- MA_DECLARE_CLASS;
-
- public:
- //----------------------------------------------------------------------------------------
- // Initialization and termination
- //----------------------------------------------------------------------------------------
-
- TPrintHandler();
- // Constructor
- virtual ~TPrintHandler();
- // Destructor
-
- void IPrintHandler(TView* itsView);
- // Initialize the printHandler, and associate it and 'itsView' with each other
-
- virtual Boolean Focus();
- // Stub
-
- virtual void FocusOnInterior();
- // Stub
-
- virtual CPoint GetQDOrigin();
- // Stub
-
- virtual VPoint GetViewToQDOffset();
- // Stub
-
- virtual TPrintInfo* GetPrintInfo();
- // Stub. Returns NULL by default
-
- virtual void SetDefaultPrintInfo();
- // Stub
-
- virtual TPrintMenuBehavior* GetManager();
- // Return the managing behavior of this print handler
-
- virtual void SetManager(TPrintMenuBehavior* itsManager);
- // Set fManager to the indicated manager
-
- virtual void SetOwner(TEventHandler* itsOwner); // override
- // Register and unregister with the window when we are added
- // to and removed from the view.
-
-
- //------------------------------------------------------------------------------------
- // Printing-related reformatting and computations
- //------------------------------------------------------------------------------------
-
- virtual void Invalidate();
- // Mark as invalid and issue a changed message
-
- virtual void Update();
- // Check if the target printer has changed and inform dependents if necessary
-
- virtual VPoint GetViewPerPage();
- // Accessor, returns amount of the view visible on a page
-
- virtual CPoint GetDeviceRes();
- // Accessor, returns formal printer resolution, spots per inch
-
- virtual VCoordinate BreakFollowing(VHSelect vhs,
- VCoordinate previousBreak,
- Boolean& automatic);
- // Returns the location of the page break which follows the page break located at
- // 'previousBreak', in direction vhs; returns automatic = true if the page-break is
- // thought of as an 'automatic' rather than a 'manual' (user-specified) one. Note
- // that page-breaks in dimension 'v' are drawn as vertical lines, those in
- // dimension 'h' as horizontal lines
-
- virtual VPoint CalcPageStrips();
- // Recalculate the number of strips of pages in each dimension
-
- virtual VPoint CalcViewPerPage();
- // Computes the amount of view, in each dimension, to be allocated to a printed
- // page
-
- virtual VPoint LocatePageInterior(long pageNumber);
- // Decide where the top-left-most point of the the interior of the page should be
-
- virtual void PrinterChanged();
- // The metrics relating to printer use have changed; absorb the information and
- // react
-
- virtual void RedoPageBreaks();
- // Recompute the dividing lines between areas of the view which will be mapped
- // into different printed pages
-
- virtual void Reset();
- // Resets the print handler to the default values
-
-
- //------------------------------------------------------------------------------------
- // Printing-related menu mgmt
- //------------------------------------------------------------------------------------
-
- virtual Boolean DoPrintCommand(CommandNumber aCommandNumber);
- // handles posting the print command, returns true if handled
-
- virtual void DoSetupPrintMenus();
- // sets up the print menus
-
-
- //------------------------------------------------------------------------------------
- // Printing-related commands
- //------------------------------------------------------------------------------------
-
- virtual Boolean Print(CommandNumber itsCommandNumber);
- // Returns TRUE to proceed.
-
- virtual Boolean SetupForFinder(CommandNumber aCommandNumber);
- // Intended to set up the print handler for finder printing.
-
-
- //------------------------------------------------------------------------------------
- // Printing-related screen feedback
- //------------------------------------------------------------------------------------
-
- virtual void DrawPrintFeedback(const VRect& area);
- // Draw page-breaks, page-numbers, view-borders, rulers, etc.
-
- virtual void DrawPageBreak(VHSelect vhs,
- long whichBreak,
- VCoordinate loc,
- Boolean automatic);
- // Does nothing.
-
-
- //------------------------------------------------------------------------------------
- // Actual printing
- //------------------------------------------------------------------------------------
-
- virtual long MaxPageNumber();
- // Returns the largest page number which could be reasonably printed, given the
- // properties of the view; in cases like a SpreadSheet, this is not necessarily as
- // large as the product (row strips) x (column strips)
-
- virtual void SetPageInterior(long pageNumber);
- // Set up the pad-space Interior rectangle for the given page number
-
- virtual void SetPageOffset(const VPoint& coord);
- // Given the view coordinates of the top-left-most CPoint of the view which is
- // being mapped into the current page (in coord), this method's job is to compute
- // the correct fRelOrigin field for the current page
-
- //----------------------------------------------------------------------------------------
- // member functions that are really stubs
- //----------------------------------------------------------------------------------------
-
- virtual void TerminateUPrinting();
- // Call to terminate the printing system
-
- virtual void PrepareForFinderPrinting(const FSSpec* targetPrinter);
- // call this to prepare for printing from the finder
- // if targetPrinter is non-NULL then it specifies a "drag print" target
-
- virtual void DispatcherIsAvailable();
- // MacApp calls this when the dispatcher has been created and initialized.
-
- virtual long GetSavePrintInfoSize(TPrintInfo* itsPrintInfo, TFile* itsFile, Boolean useRsrcFork = TRUE);
- // returns the number of bytes necessary to save the print info.
-
- virtual void SavePrintInfo(TPrintInfo* itsPrintInfo, TFile* itsFile, Boolean useRsrcFork = TRUE);
- // Saves the print info to the passed in file.
-
- virtual TPrintInfo* RestorePrintInfo(TFile* itsFile, Boolean useRsrcFork = TRUE);
- // Initializes the print info from the passed in file.
-
-
- public:
- TView* fView; // The view whose printing is handled
-
- TDocument* fDocument; // the document printed by this handler
-
- TPrintMenuBehavior* fManager; // All printhandlers are managed by a
- // seperate behavior which is installed
- // as a behavior of the document. When
- // we are detached from the document it
- // needs to know who our manager is so
- // it can remove it from its list of
- // behaviors.
-
- long fFocusedPage; // page number that is currently focused
-
- Boolean fShowBreaks; // True if page breaks should be
- // displayed at the moment
-
- protected:
- VPoint fViewPerPage; // amount of the view visible on a page
-
- CPoint fDeviceRes; // formal printer resolution, spots per
- // inch
-
- //----------------------------------------------------------------------------------------
- // static data members
- //----------------------------------------------------------------------------------------
- public:
- static Boolean gFinderPrintingProceed; // proceed with Finder printing
-
- static Boolean gCouldPrint;
- // whether Printer code is accessible to the application
-
- static VPoint gPageOffset;
- // offset in view of page being printed
-
- static TPrintHandler* gNullPrintHandler;
- // handles printing-relating messages for views which don't print
-
- static TPrintHandler* gPrintHandler;
- // a global print-handler object for use in some standard printing-related activities;
- // this is initialized to be just a reference to gNullPrintHandler, but if you call
- // InitUPrinting, that will install a non-trivial print-handler here
-
- static TPrintHandler* gCurrPrintHandler;
- // If printing, this is set to the print handler. NULL if not printing.
- };
-
-
-
- #endif // __UPRINTHANDLER__
-